#include "StdAfx.h"

#include "Neuron.h"
#include <time.h>
#include <vector>

using namespace std;
Neuron::Neuron(unsigned int inputsQuantity)throw(IllegalArgumentException)
{
	if (inputsQuantity == 0){
		throw IllegalArgumentException("Neuron Class: inputsQuantity should not be zero");
	}

	_inputsQuantity = inputsQuantity;
	_inputs.resize(inputsQuantity);

	for (unsigned int i=0; i< inputsQuantity; i++){
		Input input(0);
		_inputs[i]=input;
	}
	_output=0;
}


Neuron::~Neuron(void)
{
}

float Neuron::getOutput()
{
	return _output;
}

float Neuron::calculateOutput()
{
	_output = 0;
	for (unsigned int i=0; i<_inputs.size(); i++){
		_output+=_inputs[i].getInputValue()*_inputs[i].getWeight();
	}
	return _output;
}

std::vector<float> Neuron::getInputsValues()
{
	vector<float> inputs;
	for (unsigned int i=0; i< _inputs.size();i++){
		inputs.push_back(_inputs[i].getInputValue());
	}
	return inputs;
}

std::vector<float> Neuron::getInputsWeghts()
{
	vector<float> weights;
	for (unsigned int i=0; i< _inputs.size();i++){
		weights.push_back(_inputs[i].getWeight());
	}
	return weights;
}

int Neuron::getInputsQuantity()
{
	return _inputsQuantity;
}



void Neuron::setInputsWeights( vector <float> weights)
{
	for (unsigned int i=0; i<_inputs.size(); i++){
		_inputs[i].setWeight(weights[i]);
	}
}

void Neuron::setInputsValues( vector<float> values )
{
	for (unsigned int i=0; i<_inputs.size(); i++){
		_inputs[i].setInputValue(values[i]);
	}
}
